//***********************************************************************************
// All Regions Obstacle Map
// 1 - Obstacle, 2 - Portal, 0 - Space

// Author: Aaron Ng A0072144N

//***********************************************************************************

var ObstacleMap = {
    playerHouse : [
        [0,0,0,0,0,0,0,0,0,1],
        [0,0,0,0,0,0,0,0,0,1],
        [0,0,1,1,0,0,1,1,0,1],
        [0,0,1,1,0,0,1,1,0,1],
        [0,0,0,0,0,0,0,0,0,0],
        [0,0,0,0,0,0,0,0,0,0],
        [0,0,1,1,0,0,1,1,0,1],
        [0,0,2,1,0,0,1,1,0,1],
        [0,0,0,0,0,0,0,0,0,1],
        [1,1,1,1,0,0,1,1,1,1]],

    rebelHQ : [
        [1,1,1,1,1,1,1,0,0,0],
        [1,1,1,1,1,1,1,0,0,0],
        [1,1,1,1,1,1,1,0,0,0],
        [1,1,1,1,1,1,1,0,0,0],
        [1,1,1,2,2,1,1,0,0,0],
        [0,0,0,0,0,0,0,0,0,0],
        [0,0,0,0,0,0,0,0,0,0],
        [0,0,0,0,0,0,0,0,0,0],
        [0,0,0,0,0,0,0,0,0,0],
        [0,0,0,0,0,0,0,0,0,0]],

    tvStation : [
        [1,1,1,1,0,0,0,1,1,1],
        [0,0,0,0,0,0,0,0,0,1],
        [0,0,0,0,0,0,0,0,0,1],
        [0,0,0,1,1,1,1,1,0,1],
        [0,0,0,1,1,1,1,1,0,0],
        [0,0,0,1,1,1,1,1,0,0],
        [0,0,0,1,1,1,1,1,0,0],
        [0,0,0,1,1,2,1,1,0,1],
        [0,0,0,0,0,0,0,0,0,1],
        [0,0,0,0,0,0,0,0,0,1]],

    tvStation2 : [
        [0,0,0,0,0,0,0,0,0,0],
        [0,0,0,0,0,0,0,0,0,0],
        [0,1,1,1,1,1,1,1,1,0],
        [0,1,1,1,1,1,1,1,1,0],
        [0,0,0,0,0,0,0,0,0,0],
        [0,0,1,1,1,1,1,0,0,0],
        [0,0,1,1,1,1,1,0,0,0],
        [0,0,1,1,1,1,1,0,0,0],
        [0,0,1,1,2,1,1,1,0,0],
        [0,0,0,0,0,0,0,0,0,0]],  

    street1 : [
        [0,0,0,0,0,0,0,0,0,0],
        [0,0,1,1,0,0,1,1,0,0],
        [0,0,1,1,0,0,1,1,0,0],
        [0,0,0,0,0,0,0,0,0,0],
        [0,0,0,0,0,0,0,0,0,0],
        [0,0,0,0,0,0,0,0,0,0],
        [0,0,1,1,0,0,1,1,0,0],
        [0,0,1,1,0,0,1,1,0,0],
        [0,0,0,0,0,0,0,0,0,0],
        [0,0,0,0,0,0,0,0,0,0]],

    blackMarket : [
        [0,0,0,0,0,0,0,0,0,0],
        [0,0,0,0,0,0,0,0,0,0],
        [0,0,0,0,0,0,0,0,0,0],
        [0,0,0,0,1,1,1,1,1,0],
        [0,0,0,0,1,1,1,1,1,0],
        [0,0,0,0,1,1,1,1,1,0],
        [0,0,0,0,1,1,2,2,1,0],
        [0,0,0,0,0,0,0,0,0,0],
        [0,0,0,0,0,0,0,0,0,0],
        [0,0,0,0,0,0,0,0,0,0]],     

    armyGovt : [
        [1,0,0,1,1,1,0,0,0,0],
        [1,0,0,1,1,1,0,0,0,0],
        [1,1,1,1,1,1,1,1,1,0],
        [1,1,1,1,2,1,1,1,1,0],
        [0,0,0,0,0,0,0,0,0,0],
        [1,1,1,1,1,1,1,1,1,0],
        [1,1,1,1,1,1,1,1,1,0],
        [1,1,1,1,1,2,1,1,1,0],
        [1,0,0,0,0,0,0,0,0,0],
        [1,1,1,0,0,0,0,1,1,1]],

    inArmyHQ : [
        [1,1,1,1,1,1,1,1,1,1],
        [1,1,1,1,1,1,1,1,1,1],
        [1,1,0,0,0,0,0,0,0,0],
        [1,1,0,1,1,1,1,0,0,0],
        [1,1,0,1,1,1,1,0,0,0],
        [0,0,0,1,1,1,1,0,0,0],
        [0,0,0,0,0,0,0,0,0,0],
        [0,0,0,0,0,0,0,0,0,0],
        [0,0,0,0,0,0,0,0,0,0],
        [0,0,0,0,2,2,0,0,0,0]],

    inGovt :  [
        [1,1,1,1,1,1,1,1,1,1],
        [1,1,1,1,1,1,1,1,1,1],
        [1,1,1,1,1,1,1,1,1,1],
        [0,0,0,0,0,0,0,0,0,0],
        [1,1,1,1,0,0,1,1,1,1],
        [1,1,1,1,0,0,1,1,1,1],
        [0,1,0,1,0,0,1,0,0,0],
        [1,1,0,0,0,0,0,0,0,0],
        [0,0,0,0,0,0,0,0,0,0],
        [0,0,0,0,2,2,0,0,0,0]],

    inHome : [
        [1,1,1,1,1,1,1,1,1,1],
        [1,1,1,1,1,1,1,1,1,1],
        [1,1,1,1,0,0,0,0,0,1],
        [0,0,0,0,0,0,0,0,0,0],
        [0,0,1,1,1,1,1,0,0,0],
        [0,0,1,1,1,1,1,0,0,0],
        [0,0,0,0,0,0,0,0,0,0],
        [0,0,0,0,0,0,0,0,0,0],
        [0,0,0,0,0,0,1,1,1,1],
        [2,2,2,2,1,1,1,1,1,1]],

    inRebelHQ : [
        [1,1,1,1,1,1,1,1,1,1],
        [1,1,1,1,1,1,1,1,1,1],
        [1,1,0,0,0,0,0,0,0,0],
        [1,1,0,1,1,1,1,0,0,0],
        [1,1,0,1,1,1,1,0,0,0],
        [0,0,0,1,1,1,1,0,0,0],
        [0,0,0,0,0,0,0,0,0,0],
        [0,0,0,0,0,0,0,0,0,0],
        [0,0,0,0,0,0,0,0,0,0],
        [0,0,0,0,2,2,0,0,0,0]],

    inTvStation : [
        [1,1,1,1,1,1,1,1,1,1],
        [1,1,1,1,1,1,1,1,1,1],
        [0,0,1,1,1,1,1,1,1,0],
        [0,0,0,1,1,1,1,1,1,0],
        [0,0,0,0,0,0,0,0,0,0],
        [0,0,0,0,0,0,0,0,0,0],
        [0,0,0,0,0,0,0,0,0,0],
        [0,0,0,0,0,0,0,0,0,0],
        [0,0,0,0,0,0,0,0,0,0],
        [0,0,0,0,0,0,2,2,0,0]],

    inBlackMarket : [   

        [1,1,1,1,1,1,1,1,1,1],
        [1,1,1,1,0,0,1,1,1,1],
        [1,0,0,0,0,0,0,0,0,1],
        [0,0,0,0,0,0,0,0,0,0],
        [0,0,0,0,0,0,0,0,0,0], 
        [0,0,0,0,0,0,0,0,0,0],
        [0,0,0,0,0,0,0,1,1,1],
        [0,0,0,0,0,0,0,1,0,0],
        [0,0,0,0,0,0,0,1,0,0],
        [1,1,1,1,2,2,1,1,1,1]]

};

var BuildingList = {
    blackMarket : [
        {
            portals :
                [
                    {
                        x : 6,
                        y : 6
                    },
                    {
                        x : 7,
                        y : 6
                    }
                ],
            insidePortals :
                [
                    {
                        x : 4,
                        y : 9
                    },
                    {
                        x : 5,
                        y : 9
                    }
                ],
            type : "inBlackMarket"
        }
    ],
    armyGovt : [
        {
            portals :
                [
                    {
                        x : 4,
                        y : 3
                    }
                ],
            insidePortals :
                [
                    {
                        x : 4,
                        y : 9
                    },
                    {
                        x : 5,
                        y : 9
                    }
                ],
            type : "inGovt"
        },
        {
            portals :
                [
                    {
                        x : 5,
                        y : 7
                    }
                ],
            insidePortals :
                [
                    {
                        x : 4,
                        y : 9
                    },
                    {
                        x : 5,
                        y : 9
                    }
                ],
            type : "inArmyHQ"
        }
    ],
    rebelHQ : [
        {
            portals :
                [
                    {
                        x : 3,
                        y : 4
                    },
                    {
                        x : 4,
                        y : 4
                    }
                ],
            insidePortals :
                [
                    {
                        x : 4,
                        y : 9
                    },
                    {
                        x : 5,
                        y : 9
                    }
                ],
            type : "inRebelHQ"
        }
    ],
    tvStation : [
        {
            portals :
                [
                    {
                        x : 5,
                        y : 7
                    }
                ],
            insidePortals :
                [
                    {
                        x : 6,
                        y : 9
                    },
                    {
                        x : 7,
                        y : 9
                    }
                ],
            type : "inTvStation"
        }
    ],
    tvStation2 : [
        {
            portals :
                [
                    {
                        x : 4,
                        y : 8
                    }
                ],
            insidePortals :
                [
                    {
                        x : 6,
                        y : 9
                    },
                    {
                        x : 7,
                        y : 9
                    }
                ],
            type : "inTvStation"
        }
    ],
    street1 : [

    ],
    playerHouse : [
        {
            portals :
                [
                    {
                        x : 2,
                        y : 7
                    }
                ],
            insidePortals :
                [
                    {
                        x : 0,
                        y : 9
                    },
                    {
                        x : 1,
                        y : 9
                    },

                    {
                        x : 2,
                        y : 9
                    },
                    {
                        x : 3,
                        y : 9
                    }
                ],
            type : "inHome"
        }
    ]
};

var mapSymbol = {
    PLH : "playerHouse",

    BLM : "blackMarket",

    RHQ : "rebelHQ",

    TV1 : "tvStation",

    TV2 : "tvStation2",

    ST1 : "street1",

    AGV : "armyGovt"
};

var cityMap = [
    ["BLM", "ST1", "ST1", "ST1", "ST1", "ST1", "ST1", "ST1", "ST1", "ST1"],
    ["ST1", "ST1", "RHQ", "ST1", "ST1", "ST1", "TV2", "ST1", "ST1", "ST1"],
    ["ST1", "RHQ", "RHQ", "RHQ", "ST1", "ST1", "ST1", "ST1", "TV1", "ST1"],
    ["TV2", "ST1", "RHQ", "ST1", "ST1", "ST1", "ST1", "ST1", "ST1", "ST1"],
    ["ST1", "ST1", "ST1", "ST1", "ST1", "ST1", "ST1", "ST1", "ST1", "ST1"],
    ["ST1", "ST1", "ST1", "ST1", "PLH", "ST1", "ST1", "ST1", "ST1", "TV2"],
    ["ST1", "ST1", "TV2", "ST1", "ST1", "ST1", "ST1", "AGV", "ST1", "ST1"],
    ["ST1", "ST1", "ST1", "ST1", "ST1", "ST1", "AGV", "AGV", "AGV", "ST1"],
    ["ST1", "TV1", "ST1", "ST1", "TV1", "ST1", "ST1", "AGV", "ST1", "ST1"],
    ["ST1", "ST1", "ST1", "ST1", "ST1", "ST1", "ST1", "ST1", "TV1", "ST1"]
];


var armyGovtImg;
var tvStationImg;
var rebelHQImg;
var playerHouseImg;